//
//  MoyaCacheFloatingView.swift
//  Common
//
//  Created by 我骑着蜗牛走天下 on 2025/11/14.
//

import UIKit

public class MoayCachefloatingView: UNFloatingView {
    
    override init(frame: CGRect) {
        super.init(frame: .init(x: MainWidth - 72, y: MainHeight / 3, width: 72, height: 82))
        
        backgroundColor = .white
        
        addSubview(iconImageView)
        iconImageView.translatesAutoresizingMaskIntoConstraints = false

        NSLayoutConstraint.activate([
            iconImageView.centerYAnchor.constraint(equalTo: self.centerYAnchor),
            iconImageView.centerXAnchor.constraint(equalTo: self.centerXAnchor),
            iconImageView.widthAnchor.constraint(equalToConstant: 42),
            iconImageView.heightAnchor.constraint(equalToConstant: 42)
        ])
        
    }
    
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    override public func handleTapGesture() {
        
        let nav = UINavigationController(rootViewController: MoyaCacheRequestList() )
        nav.modalPresentationStyle = .fullScreen // 设置为全屏
        getCurrentVC.present(nav, animated: true, completion: nil)
        
    }
    
    override public func progressDidChange(_ progress: Double) {
        iconImageView.alpha = 1 - progress
    }
    
    lazy var iconImageView: UIImageView = {
        let img = UIImageView(image: UIImage(named: "icon_debug", in: .module, compatibleWith: nil))
        return img
    }()
    
}
